<html>
<head></head>
<body>
<?php
//following Doza's MySQL connection example I will highlight what this page does.
$conn = new mysqli('localhost','root','','SEVENBITS','3306');
if(mysqli_connect_errno()){
echo "connection failed";
}else {
echo "connection successful";
echo "<br>". $_GET['ID']. " : ".$_GET['WDID'] ."<br>";

}
$sql = "SELECT * FROM roledate ";
$result = $conn->query($sql);
//on this page we create 2 variables that collect the information from the variables in the url
//to be used in the update shown below.
$rid = $_GET['ID'];
$DID = $_GET['WDID'];
//this update is changing the status of the given shift to Avaiable, thus adjusting the shift
$updater = "UPDATE roledate SET ShiftStatus = 'Available' WHERE RoleID = $rid AND DateID = $DID";
//a similar update could be used to change a shift from one employee to another.
echo $rid . " : " . $DID;

if($result->num_rows>0){
while($row = $result->fetch_assoc()){
if($row['RoleID']==$_GET['ID']&&$row['DateID']==$_GET['WDID']){
echo "<br> id: " . $row['RoleID']."  ".$row['ShiftStatus']. " : " . $row['RequestPendingApproval']. " : ";
echo "this will be updated!";
//this line updates the selected row
$conn->query($updater);
}
}
}
else{
echo "no Shifts scheduled ";
}

$conn->close();


?>
</body>
</html>